package jnpf.service.impl;

import jnpf.entity.Whu_professionalabilityEntity;
import jnpf.mapper.Whu_professionalabilityMapper;
import jnpf.service.Whu_professionalabilityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.util.RandomUtil;


import jnpf.model.whu_professionalability.Whu_professionalabilityPagination;
import java.util.stream.Collectors;





import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.text.SimpleDateFormat;
import jnpf.util.*;
import java.util.*;

/**
 *
 * whu_professionalability
 * 版本： V3.2.0
 * 版权： 引迈信息技术有限公司（https://www.jnpfsoft.com）
 * 作者： JNPF开发平台组
 * 日期： 2025-06-10
 */
@Service

public class Whu_professionalabilityServiceImpl extends ServiceImpl<Whu_professionalabilityMapper, Whu_professionalabilityEntity> implements Whu_professionalabilityService {

    @Autowired
    private UserProvider userProvider;






    @Override
    public List<Whu_professionalabilityEntity> getList(Whu_professionalabilityPagination whu_professionalabilityPagination){
        String userId=userProvider.get().getUserId();
        List<String> AllIdList =new ArrayList();
        int total=0;
        QueryWrapper<Whu_professionalabilityEntity> whu_professionalabilityQueryWrapper=new QueryWrapper<>();

        whu_professionalabilityQueryWrapper.lambda().like(Whu_professionalabilityEntity::getUserid,userId);


        if(AllIdList.size()>0){
            whu_professionalabilityQueryWrapper.lambda().in(Whu_professionalabilityEntity::getId, AllIdList);
        }
        //排序
        if(StringUtil.isEmpty(whu_professionalabilityPagination.getSidx())){
        whu_professionalabilityQueryWrapper.lambda().orderByDesc(Whu_professionalabilityEntity::getId);
        }else{
        whu_professionalabilityQueryWrapper="asc".equals(whu_professionalabilityPagination.getSort().toLowerCase())?whu_professionalabilityQueryWrapper.orderByAsc(whu_professionalabilityPagination.getSidx()):whu_professionalabilityQueryWrapper.orderByDesc(whu_professionalabilityPagination.getSidx());
        }
        if((total>0 && AllIdList.size()>0) || total==0){
        Page<Whu_professionalabilityEntity> page=new Page<>(whu_professionalabilityPagination.getCurrentPage(), whu_professionalabilityPagination.getPageSize());
        IPage<Whu_professionalabilityEntity> userIPage=this.page(page, whu_professionalabilityQueryWrapper);
        return whu_professionalabilityPagination.setData(userIPage.getRecords(),userIPage.getTotal());
        }else{
            List<Whu_professionalabilityEntity> list = new ArrayList();
            return whu_professionalabilityPagination.setData(list, list.size());
        }
    }
    @Override
    public List<Whu_professionalabilityEntity> getTypeList(Whu_professionalabilityPagination whu_professionalabilityPagination,String dataType){
        String userId=userProvider.get().getUserId();
        List<String> AllIdList =new ArrayList();
		int total=0;
        QueryWrapper<Whu_professionalabilityEntity> whu_professionalabilityQueryWrapper=new QueryWrapper<>();

        whu_professionalabilityQueryWrapper.lambda().like(Whu_professionalabilityEntity::getUserid,userId);


		if(AllIdList.size()>0){
        whu_professionalabilityQueryWrapper.lambda().in(Whu_professionalabilityEntity::getId, AllIdList);
				}
        //排序
        if(StringUtil.isEmpty(whu_professionalabilityPagination.getSidx())){
        whu_professionalabilityQueryWrapper.lambda().orderByDesc(Whu_professionalabilityEntity::getId);
        }else{
        whu_professionalabilityQueryWrapper="asc".equals(whu_professionalabilityPagination.getSort().toLowerCase())?whu_professionalabilityQueryWrapper.orderByAsc(whu_professionalabilityPagination.getSidx()):whu_professionalabilityQueryWrapper.orderByDesc(whu_professionalabilityPagination.getSidx());
        }
        if("0".equals(dataType)){
            if((total>0 && AllIdList.size()>0) || total==0){
                Page<Whu_professionalabilityEntity> page=new Page<>(whu_professionalabilityPagination.getCurrentPage(), whu_professionalabilityPagination.getPageSize());
                IPage<Whu_professionalabilityEntity> userIPage=this.page(page, whu_professionalabilityQueryWrapper);
                return whu_professionalabilityPagination.setData(userIPage.getRecords(),userIPage.getTotal());
            }else{
                List<Whu_professionalabilityEntity> list = new ArrayList();
                return whu_professionalabilityPagination.setData(list, list.size());
            }
        }else{
            return this.list(whu_professionalabilityQueryWrapper);
        }
    }

    @Override
    public Whu_professionalabilityEntity getInfo(String id){
        QueryWrapper<Whu_professionalabilityEntity> queryWrapper=new QueryWrapper<>();
        queryWrapper.lambda().eq(Whu_professionalabilityEntity::getId,id);
        return this.getOne(queryWrapper);
    }

    @Override
    public void create(Whu_professionalabilityEntity entity){
        String userId = userProvider.get().getUserId();
        entity.setUserid(userId);
        this.save(entity);
    }

    @Override
    public boolean update(String id, Whu_professionalabilityEntity entity){
        entity.setId(id);
        return this.updateById(entity);
    }
    @Override
    public void delete(Whu_professionalabilityEntity entity){
        if(entity!=null){
            this.removeById(entity.getId());
        }
    }
    //子表方法

    //列表子表数据方法

}
